package com.spider.iceCream.mapper;

import com.spider.iceCream.entity.Video;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Lord
 * @date 2021/7/13 9:24
 */
@Mapper
@Repository
public interface VideoMapper {
    /**
     * 返回是否存在视频信息
     * @param oid 视频id
     * @return true or false
     */
    @Select("select * from video where oid = #{oid}")
    public Video isExistVideo (Integer oid);

    /**
     * 返回是否存在视频信息
     * @param BV 视频id
     * @return true or false
     */
    @Select("select * from video where url like '%${BV}' or name like '%${BV}%' ")
    public List<Video> getVideoByBV(String BV);

    /**
     * 添加视频
     * @param video 视频信息
     * @return true or false
     */
    @Insert("insert into video (oid,cid,name,upper,url,imgUrl) values (#{oid},#{cid},#{name},#{upper},#{url},#{imgUrl})")
    public int insertVideo(Video video);

    /**
     * 返回是否存在视频信息
     */
    @Select("select * from video where 1")
    public List<Video> test();

    /**
     * 更新up主
     * @param video test
     * @return true or false
     */
    @Update("update video set upper = #{upper} where oid = #{oid}")
    public int updateUpper(Video video);

    /**
     * 更新图片
     * @param video test
     * @return true or false
     */
    @Update("update video set imgUrl = #{imgUrl} where oid = #{oid}")
    public int updateImgUrl(Video video);
}
